﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Refugees.Views.Windows
{
    /// <summary>
    /// Логика взаимодействия для UserEdit.xaml
    /// </summary>
    public partial class UserEdit : Window
    {
        Models.User user;
        Repositories.OrganizationRepository organizationRepository = new Repositories.OrganizationRepository();
        Repositories.UserRepository userRepository = new Repositories.UserRepository();
        public UserEdit(Models.User user)
        {
            InitializeComponent();
            Roles.ItemsSource = userRepository.Roles();
            Organization.ItemsSource = organizationRepository.GetOrganizations();
            this.user = user;
            DataContext = this.user;
        }

        private void SaveClick(object sender, RoutedEventArgs e)
        {
            if (Repositories.ModelRepository.Save())
            {
                MessageBox.Show("Данные сохранены успешно");
            }
            else
            {
                MessageBox.Show("Данные не сохранены. Повторите попытку позже или проверьте данные");
            }
        }

        private void BackClick(object sender, RoutedEventArgs e)
        {
            new UserAdmin().Show();
            Close();
        }
    }
}
